package vip.ola.service.dao.mapper.code;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import vip.ola.core.entity.code.CodeInfo;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;


/**
 * <p>
 * 二维码信息 Mapper 接口
 * </p>
 *
 * @author faker
 * @since 2020-03-25
 */
public interface CodeInfoMapper extends BaseMapper<CodeInfo> {

    IPage<CodeInfo> list(Page page, @Param("codeInfo") CodeInfo codeInfo);

    CodeInfo getByCodeInfo(@Param("codeInfo") CodeInfo codeInfo);

    CodeInfo getByCodeUrl(@Param("codeUrl") String codeUrl);

    List<CodeInfo> getAvailableQrCode(@Param("codeBusId") Long codeBusId, @Param("codeType") Integer codeType,
                                      @Param("amount") BigDecimal amount, @Param("needThirdId") boolean needThirdId,
                                      @Param("offset") int offset, @Param("limit") int limit);

    List<CodeInfo> getAvailableBestQrCode(@Param("codeBusId") Long codeBusId, @Param("codeType") Integer codeType,
                                      @Param("amount") BigDecimal amount, @Param("needThirdId") boolean needThirdId,
                                      @Param("offset") int offset, @Param("limit") int limit);

    int updateCodeCollInfo(@Param("codeId") Long codeId, @Param("amount") BigDecimal amount,
                           @Param("profit") BigDecimal profit, @Param("weight") int weight, @Param("nextTime") LocalDateTime nextTime);

    int cleanCodeCollInfo(@Param("codeBusId") Long codeBusId, @Param("agentId") Long agentId, @Param("userId") Long userId, @Param("weight") int weight);

    int updateCodeAgentRate(long agentId, BigDecimal rate);

    int updateCodeBusRate(long codeBusId, BigDecimal rate);

    int updateFailWeight(@Param("idList") List idList, @Param("weight") int weight);

    int delCodeByTime(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
    int delCodeOrderByTime(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
    int delCodeUserByTime(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
    int delCodeAccountHistoryByTime(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
    int delPassageSettByTime(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
}
